package com.buba.controller;


import com.buba.service.DailyRecordService;
import entity.CommentEntiry;
import entity.DailyRecordEntity;
import entity.KudosEntity;
import entity.ReplyCommentEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import result.CommonResult;

/**
 * 日记本列表
 * LC: 2022-11-16 10:16
 */
@RestController
@CrossOrigin
public class DailyRecordController {

    @Autowired
    DailyRecordService diaryService;

    /**
     * 查询是否收藏
     * @param
     * @return
     */
    @GetMapping("/getCollection/{id}/{collectionDictionaries}/{collectionUserId}")
    public CommonResult getCollection(@PathVariable("id")Integer id,
                                     @PathVariable("collectionDictionaries")Integer collectionDictionaries,
                                     @PathVariable("collectionUserId")Integer collectionUserId){
        return CommonResult.ok(diaryService.getCollection(id,collectionDictionaries,collectionUserId));
    }
    /**
     * 新增关注
     * @param id
     * @return
     */
    @GetMapping("/getFollowUserId")
    public CommonResult getFollowUserId(Integer id,Integer userId) {
        return CommonResult.ok(diaryService.getFollowUserId(id,userId));
    }
    /**
     * 查询关注
     * @param id
     * @return
     */
    @GetMapping("/getFollowUser")
    public CommonResult getFollowUser(Integer id,Integer userId) {
        return CommonResult.ok(diaryService.getFollowUser(id,userId));
    }
    /**
     * 根据id查询日记评论、点赞
     * @param id
     * @return
     */
    @GetMapping("/getDailyRecordIdOne")
    public CommonResult getDailyRecordIdOne(Integer id) {
        return CommonResult.ok(diaryService.getDailyRecordIdOne(id));
    }

    /**
     * 全查日记
     * @return
     */
    @GetMapping("/getDailyRecordRj")
    public CommonResult getDailyRecordRj(){
        return CommonResult.ok(diaryService.getDailyRecordRj());
    }
    /**
     * 根据id查询日记
     * @param id
     * @return
     */
    @GetMapping("/getDailyRecordById")
    public CommonResult getDailyRecordById(Integer id,Integer userId){
        return CommonResult.ok(diaryService.getDailyRecordById(id,userId));
    }

    /**
     * 新增浏览量
     * @param dailyRecordEntity
     * @return
     */
    @PostMapping("/editDailyRecordBrowse")
    public CommonResult editDailyRecordBrowse(@RequestBody DailyRecordEntity dailyRecordEntity){
        return CommonResult.ok(diaryService.editDailyRecordBrowse(dailyRecordEntity));
    }

    /**
     * 新增评论
     * @param commentEntiry
     * @return
     */
    @PostMapping("/saveComment")
    public CommonResult saveComment(@RequestBody CommentEntiry commentEntiry){
        return diaryService.saveComment(commentEntiry);
    }

    /**
     * 根据id查询评论
     * @param id
     * @return
     */
    @GetMapping("/getCommentById")
    public CommonResult getCommentById(Integer id, String commentDictionaries,Integer userId){
        return CommonResult.ok(diaryService.getCommentById(id,commentDictionaries,userId));
    }

    /**
     * 根据id查询评论数量
     * @param id
     * @return
     */
    @GetMapping("/getCommentNum")
    public CommonResult getCommentNum(Integer id, String commentDictionaries){
        return CommonResult.ok(diaryService.getCommentNum(id,commentDictionaries));
    }

    /**
     * 点赞
     * @param
     * @return
     */
    @PostMapping("/getKudosNum")
    public CommonResult getKudosNum(@RequestBody KudosEntity kudosEntity){
        return CommonResult.ok(diaryService.getKudosNum(kudosEntity));
    }
    /**
     * 查询是否点赞
     * @param
     * @return
     */
    @GetMapping("/getKudosById/{id}/{kudosDictionaries}/{kudosUserId}")
    public CommonResult getKudosById(@PathVariable("id")Integer id,
                                     @PathVariable("kudosDictionaries")Integer kudosDictionaries,
                                     @PathVariable("kudosUserId")Integer kudosUserId){
        return CommonResult.ok(diaryService.getKudosById(id,kudosDictionaries,kudosUserId));
    }

    /**
     * 根据id查询日记本图片
     * @param id
     * @return
     */
    @GetMapping("/getdiaryFile/{id}")
    public CommonResult getdiaryFile(@PathVariable("id")Integer id){
        return CommonResult.ok(diaryService.getdiaryFile(id));
    }

    /**
     * 根据id查询日记本用户
     * @param id
     * @return
     */
    @GetMapping("/getdiaryUser/{id}")
    public CommonResult getdiaryUser(@PathVariable("id")Integer id){
        return CommonResult.ok(diaryService.getdiaryUser(id));
    }

    /**
     * 日记本详情轮播图片
     * @param id
     * @return
     */
    @GetMapping("/getDailyRecordFileById/{id}")
    public CommonResult getDailyRecordFileById(@PathVariable("id")Integer id){
        return CommonResult.ok(diaryService.getDailyRecordFileById(id));
    }

    /**
     * 评论点赞
     * @param id
     * @param kudosDictionaries
     * @param kudosUserId
     * @param commentDiaryRecordId
     * @return
     */
    @GetMapping("/getCommentKudosById/{id}/{kudosDictionaries}/{kudosUserId}/{commentDiaryRecordId}")
    public CommonResult getCommentKudosById(@PathVariable("id") Integer id,
                                            @PathVariable("kudosDictionaries")Integer kudosDictionaries,
                                            @PathVariable("kudosUserId")Integer kudosUserId,
                                            @PathVariable("commentDiaryRecordId") Integer commentDiaryRecordId) {
        return CommonResult.ok(diaryService.getCommentKudosById(id,kudosDictionaries,kudosUserId,commentDiaryRecordId));
    }



}
